from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, 
                            QComboBox, QLabel, QDoubleSpinBox, QLineEdit)

class PortControlWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()
    
    def init_ui(self):
        self.port_combo = QComboBox()
        self.baud_combo = QComboBox()
        self.baud_combo.addItems(["9600", "19200", "38400", "57600", "115200", "921600", "2000000"])
        self.baud_combo.setCurrentText("921600")
        self.connect_btn = QPushButton("连接")
        self.refresh_btn = QPushButton("刷新")
        
        layout = QHBoxLayout()
        layout.addWidget(QLabel("端口:"))
        layout.addWidget(self.port_combo)
        layout.addWidget(QLabel("波特率:"))
        layout.addWidget(self.baud_combo)
        layout.addWidget(self.connect_btn)
        layout.addWidget(self.refresh_btn)
        layout.addStretch()
        self.setLayout(layout)

class FileControlWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()
    
    def init_ui(self):
        self.file_btn = QPushButton("选择文件")
        self.interval_spin = QDoubleSpinBox()
        self.interval_spin.setRange(0, 1000)
        self.interval_spin.setSingleStep(1)
        self.interval_spin.setValue(0.001)
        self.interval_spin.setSuffix(" ms")
        self.send_btn = QPushButton("发送")
        
        layout = QHBoxLayout()
        layout.addWidget(self.file_btn)
        layout.addWidget(QLabel("字节间隔:"))
        layout.addWidget(self.interval_spin)
        layout.addWidget(self.send_btn)
        layout.addStretch()
        self.setLayout(layout)

class MessageInputWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()
    
    def init_ui(self):
        self.message_input = QLineEdit()
        self.message_input.setPlaceholderText("输入要发送的消息...")
        self.send_btn = QPushButton("发送消息")
        
        layout = QHBoxLayout()
        layout.addWidget(self.message_input)
        layout.addWidget(self.send_btn)
        self.setLayout(layout)        